<!doctype html>
<html lang="zh-CN">

<head>
    <script src="http://apps.bdimg.com/libs/jquery/1.7.0/jquery.min.js"></script>
    <link rel="stylesheet" type="text/css" href="css/default.css"/>
    <link rel="stylesheet" type="text/css" href="css/component.css"/>
    <!--<link rel="stylesheet" type="text/css" href="css/buttons.css" />-->
    <script src="js/modernizr.custom.js"></script>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
    <title>慢性病分布</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }

        html,body {
            height: 100%;
            margin: 0;
            width: 100%;
            padding: 0;
            overflow: hidden;
            font-size: 13px;
        }

        .map {
            height: 100%;
            width: 100%;
            float: left;
        }

        #right {
            color: #444;
            background-color: #f8f8f8;
            width: 40%;
            float: right;
            height: 100%;
        }

        #start,
        #stop,
        #right input {
            margin: 4px;
            margin-left: 15px;
        }

        .title {
            width: 100%;
            background-color: #dadada
        }

        /*button {*/
        /*border: solid 1px;*/
        /*margin-left: 15px;*/
        /*background-color: #dadafa;*/
        /*}*/

        .c {
            font-weight: 600;
            padding-left: 15px;
            padding-top: 4px;
        }

        #lnglat,
        #address,
        #nearestJunction,
        #nearestRoad,
        #nearestPOI,
        .title {
            padding-left: 15px;
        }

        .button-group {
            position: absolute;
            bottom: 20px;
            /*right: 20px;*/
            font-size: 12px;
            padding: 10px;
        }

        .button-group .button {
            height: 28px;
            line-height: 28px;
            background-color: #4a500e;
            color: #FFF;
            border: 0;
            outline: none;
            padding-left: 5px;
            padding-right: 5px;
            border-radius: 3px;
            margin-bottom: 4px;
            cursor: pointer;
        }

        .button-group .inputtext {
            height: 26px;
            line-height: 26px;
            border: 1px;
            outline: none;
            padding-left: 5px;
            padding-right: 5px;
            border-radius: 3px;
            margin-bottom: 4px;
            cursor: pointer;
        }

        /*
       .tip {
           position: absolute;
           bottom: 30px;
           right: 10px;
           background-color: #FFF;
           text-align: center;
           border: 1px solid #ccc;
           line-height: 30px;
           border-radius: 3px;
           padding: 0 5px;
           font-size: 12px;
       }
       */
        #tip {
            background-color: #fff;
            padding-left: 10px;
            padding-right: 10px;
            position: absolute;
            font-size: 12px;
            right: 10px;
            top: 20px;
            border-radius: 3px;
            border: 1px solid #ccc;
            line-height: 30px;
        }

        .red-button {
            height: 28px;
            line-height: 28px;
            background-color: #ff0441;
            color: #FFF;
            border: 0;
            outline: none;
            padding-left: 5px;
            padding-right: 5px;
            border-radius: 3px;
            margin-bottom: 4px;
            cursor: pointer;
        }

        .amap-info-content {
            font-size: 12px;
        }

        #myPageTop {
            position: absolute;
            bottom: 16px;
            left: 323px;
            background: #fff none repeat scroll 0 0;
            border: 1px solid #ccc;
            margin: 10px auto;
            padding: 6px;
            font-family: "Microsoft Yahei", "微软雅黑", "Pinghei";
            font-size: 14px;
        }

        #myPageTop label {
            margin: 0 20px 0 0;
            color: #666666;
            font-weight: normal;
        }

        #myPageTop input {
            width: 170px;
        }

        #myPageTop .column2 {
            padding-left: 25px;
        }

        /*列表样式*/
        #n {
            margin: 10px auto;
            width: 920px;
            border: 1px solid #CCC;
            font-size: 14px;
            line-height: 30px;
        }

        #n a {
            padding: 0 4px;
            color: #333
        }

        .Bar, .Bars {
            position: relative;
            width: 200px;
            /* 宽度 */
            border: 1px solid #B1D632;
            padding: 1px;
        }

        .Bar div, .Bars div {
            display: block;
            position: relative;
            background: #00F; /* 进度条背景颜色 */
            color: #333333;
            height: 20px; /* 高度 */
            line-height: 20px;
            /* 必须和高度一致，文本才能垂直居中 */
        }

        .Bars div {
            background: #090
        }

        .Bar div span, .Bars div span {
            position: absolute;
            width: 200px;
            /* 宽度 */
            text-align: center;
            font-weight: bold;
        }

        .cent {
            margin: 0 auto;
            width: 300px;
            overflow: hidden
        }
        a:hover {
            color: #eadede;
        }
        /*大按钮*/
        .BIGbutton {
            position: relative;
            color: rgba(255, 255, 255, 1);
            text-decoration: none;
            background-color: rgba(219, 87, 5, 1);
            font-family: 'Yanone Kaffeesatz';
            font-weight: 700;
            font-size: 2em;
            display: block;
            padding: 4px;
            -webkit-border-radius: 8px;
            -moz-border-radius: 8px;
            border-radius: 8px;
            -webkit-box-shadow: 0px 9px 0px rgba(219, 31, 5, 1), 0px 9px 25px rgba(0, 0, 0, .7);
            -moz-box-shadow: 0px 9px 0px rgba(219, 31, 5, 1), 0px 9px 25px rgba(0, 0, 0, .7);
            box-shadow: 0px 9px 0px rgba(219, 31, 5, 1), 0px 9px 25px rgba(0, 0, 0, .7);
            margin: 20px auto;
            width: 160px;
            text-align: center;

            -webkit-transition: all .1s ease;
            -moz-transition: all .1s ease;
            -ms-transition: all .1s ease;
            -o-transition: all .1s ease;
            transition: all .1s ease;
        }

        .BIGbutton:active {
            -webkit-box-shadow: 0px 3px 0px rgba(219, 31, 5, 1), 0px 3px 6px rgba(0, 0, 0, .9);
            -moz-box-shadow: 0px 3px 0px rgba(219, 31, 5, 1), 0px 3px 6px rgba(0, 0, 0, .9);
            box-shadow: 0px 3px 0px rgba(219, 31, 5, 1), 0px 3px 6px rgba(0, 0, 0, .9);
            position: relative;
            top: 6px;
        }

        .SmallButton {
            float: right;
            position: relative;
            color: rgba(255, 255, 255, 1);
            text-decoration: none;
            background-color: rgba(219, 87, 5, 1);
            font-family: 'Yanone Kaffeesatz';
            font-weight: 700;
            font-size: 1.3em;
            display: block;
            padding: 0px;
            -webkit-border-radius: 8px;
            -moz-border-radius: 8px;
            border-radius: 8px;
            -webkit-box-shadow: 0px 9px 0px rgba(219, 31, 5, 1), 0px 9px 25px rgba(0, 0, 0, .7);
            -moz-box-shadow: 0px 9px 0px rgba(219, 31, 5, 1), 0px 9px 25px rgba(0, 0, 0, .7);
            box-shadow: 0px 9px 0px rgba(219, 31, 5, 1), 0px 9px 25px rgba(0, 0, 0, .7);
            margin: -7px auto;
            width: 60px;
            text-align: center;

            -webkit-transition: all .1s ease;
            -moz-transition: all .1s ease;
            -ms-transition: all .1s ease;
            -o-transition: all .1s ease;
            transition: all .1s ease;
        }
        .daye {
            float: right;
            position: relative;
            color: rgba(255, 255, 255, 1);
            text-decoration: none;
            background-color: rgba(219, 87, 5, 1);
            font-family: 'Yanone Kaffeesatz';
            font-weight: 700;
            font-size: 1.3em;
            display: block;
            padding: 0px;
            -webkit-border-radius: 8px;
            -moz-border-radius: 8px;
            border-radius: 8px;
            -webkit-box-shadow: 0px 9px 0px rgba(219, 31, 5, 1), 0px 9px 25px rgba(0, 0, 0, .7);
            -moz-box-shadow: 0px 9px 0px rgba(219, 31, 5, 1), 0px 9px 25px rgba(0, 0, 0, .7);
            box-shadow: 0px 9px 0px rgba(219, 31, 5, 1), 0px 9px 25px rgba(0, 0, 0, .7);
            margin: 1px 33px 15px -19px;
            width: 60px;
            text-align: center;

            -webkit-transition: all .1s ease;
            -moz-transition: all .1s ease;
            -ms-transition: all .1s ease;
            -o-transition: all .1s ease;
            transition: all .1s ease;
        }

        .yigong {
            float: right;
            position: relative;
            color: rgba(255, 255, 255, 1);
            text-decoration: none;
            background-color: #4196ff;
            font-family: 'Yanone Kaffeesatz';
            font-weight: 700;
            font-size: 1.3em;
            display: block;
            padding: 0px;
            -webkit-border-radius: 8px;
            -moz-border-radius: 8px;
            border-radius: 8px;
            -webkit-box-shadow: 0px 9px 0px #6485af, 0px 9px 25px rgba(251, 251, 251, .7);
            -moz-box-shadow: 0px 9px 0px #6485af, 0px 9px 25px rgba(251, 251, 251, .7);
            box-shadow: 0px 9px 0px #6485af, 0px 9px 25px rgba(251, 251, 251, 0.7);
            margin: 1px 33px 15px -19px;
            width: 80px;
            text-align: center;

            -webkit-transition: all .1s ease;
            -moz-transition: all .1s ease;
            -ms-transition: all .1s ease;
            -o-transition: all .1s ease;
            transition: all .1s ease;
        }

        .SmallButton:active {
            -webkit-box-shadow: 0px 3px 0px rgba(219, 31, 5, 1), 0px 3px 6px rgba(0, 0, 0, .9);
            -moz-box-shadow: 0px 3px 0px rgba(219, 31, 5, 1), 0px 3px 6px rgba(0, 0, 0, .9);
            box-shadow: 0px 3px 0px rgba(219, 31, 5, 1), 0px 3px 6px rgba(0, 0, 0, .9);
            position: relative;
            top: 6px;
        }

        .OKButton {
            float: right;
            position: relative;
            color: rgba(255, 255, 255, 1);
            text-decoration: none;
            background-color: rgba(219, 87, 5, 1);
            font-family: 'Yanone Kaffeesatz';
            font-weight: 700;
            font-size: 1.3em;
            display: block;
            padding: 0px;
            -webkit-border-radius: 8px;
            -moz-border-radius: 8px;
            border-radius: 8px;
            -webkit-box-shadow: 0px 9px 0px rgba(219, 31, 5, 1), 0px 9px 25px rgba(0, 0, 0, .7);
            -moz-box-shadow: 0px 9px 0px rgba(219, 31, 5, 1), 0px 9px 25px rgba(0, 0, 0, .7);
            box-shadow: 0px 9px 0px rgba(219, 31, 5, 1), 0px 9px 25px rgba(0, 0, 0, .7);
            margin: -7px auto;
            width: 60px;
            text-align: center;

            -webkit-transition: all .1s ease;
            -moz-transition: all .1s ease;
            -ms-transition: all .1s ease;
            -o-transition: all .1s ease;
            transition: all .1s ease;
        }

        .cbp-spmenu h3 {
            color: #fffefe;
            font-size: 1.5em;
            padding: 10px;
        }

        .close {
            position: absolute;
            right: 3px;
            top: 1px;
            width: 42px;
            height: 42px;
            background: silver;
            border-radius: 25px;
            box-shadow: 2px 2px 5px 0px #888;
            cursor: pointer;
        }

        .close:hover {
            background: #a8c6d8;
        }

        .close:before {
            position: absolute;
            content: '';
            width: 30px;
            height: 9px;
            background: white;
            transform: rotate(45deg);
            top: 18px;
            left: 7px;
        }

        .close:after {
            content: '';
            position: absolute;
            width: 30px;
            height: 9px;
            background: white;
            transform: rotate(-45deg);
            top: 17px;
            left: 7px;
        }
    </style>
</head>

<body>
<div class="button-group" style="z-index: 9999;    margin-left: 240px;">
    <input id="setCenter" type="button" class="button" value="清屏" onclick="javascript:initMap(null,true);"/>
    <input type="button" class="button" id="showRight" value="附近志愿者" onClick="javascript:showYG('yg')"/>
    <input type="button" class="button" id="showLeft" value="急救通道" onClick="javascript:void(0);"/>
    <input type="button" class="button" id="showRightPush" value="SOS列表" onClick="javascript:void(0);"/>
</div>
<div id="container" class="map" tabindex="0"></div>

<nav class="cbp-spmenu cbp-spmenu-vertical cbp-spmenu-left" id="cbp-spmenu-s1">
    <h3>SOS急救通道
        <div class="close" onclick="showLeft.click()"></div>
    </h3>
    <a href="javascript:getLoc('relatives');" target="_blank" style="background: orangered">
        亲属 ( 未拨通 )
        <div href="javascript:callFun.call('relatives');" class="SmallButton" id="relatives">重拨</div>
    </a>
    <a href="javascript:getLoc('doctor');" target="_blank" style="background: orangered">医生 ( 未拨通 )
        <div href="javascript:callFun.call('doctor');" class="SmallButton" id="doctor">重拨</div>
    </a>
    <a href="javascript:getLoc('socialWorker');" target="_blank" style="background: forestgreen">社工 ( 已拨通 )
        <div href="javascript:callFun.call('socialWorker');" class="SmallButton" id="socialWorker">重拨</div>
    </a>
    <!--<a href="javascript:getLoc('hospital');" target="_blank" style="background: yellowgreen">医院 ( 连通中 )-->
        <!--<div href="javascript:callFun.call('hospital');" class="SmallButton" id="hospital">重拨</div>-->
    <!--</a>-->
    <h3>详细信息</h3>
    <a>
        <p id="username"></p>
        <dl>
            <dt></dt>
            <dd>电话 : 010-84107000 </dd>
            <dd>地址 :浙江省杭州市下城区朝晖街道朝晖九小区(潮王支路)朝晖九小区</dd>
        </dl>
    </a>
    <a>既往病史
        <dl>
            <dd>①患有先天性心脏病室间隔缺损，缺损0.3cm，曾在省人民医院确诊，不需要手术。</dd>
        </dl>
    </a>
    </a>
    <h3>动态(步行导航)</h3>
    <a href="javascript:void(0);" target="_blank" id="walking_navigation_info" style="padding: 0.2em;"></a>
</nav>

<nav class="cbp-spmenu cbp-spmenu-vertical cbp-spmenu-right" id="cbp-spmenu-s3">
    <h3>SOS人员列表
        <div class="close" onclick="showRightPush.click()"></div>
    </h3>
    <a href="javascript:openInfo(0,'胡大爷');" target="_blank">胡大爷</a>
    <a href="javascript:openInfo(1,'李大爷');" target="_blank">李大爷</a>
    <a href="javascript:openInfo(2,'张大爷');" target="_blank">张大爷</a>
    <h3>动态信息</h3>
    <marquee direction="up" truespeed="truespeed" height="400px" behavior="scroll" scolldelay="150"  scrollamount="1">
        <a href="#">9:13 志愿者6正在赶往张大爷位置</a><br/>
        <a href="#">9:26 社区医院1接收张大爷</a><br/>
        <a style="color:red" href="#">9:27 胡大爷发出sos急救请求</a><br/>
        <a href="#">9:27 胡大爷急救请求已和家属接通</a><br/>
        <a href="#">9:31 志愿者6已到达张大爷位置</a><br/>
        <a href="#">9:45 社区医院为张大爷安排转院手续</a><br/>
        <a style="color:red" href="#">11:27 王大爷发出sos急救请求</a><br/>
        <a href="#">11:28 志愿者3正在赶往王大爷位置</a><br/>
        <a style="color:red" href="#">11:29 志愿者3路上发生状况请求援助</a><br/>
        <a href="#">11:29 志愿者5正在赶往王大爷位置</a><br/>
        <a href="#">11:31 志愿者5已到达张大爷位置</a><br/>
    </marquee>
</nav>

<nav class="diycss cbp-spmenu cbp-spmenu-vertical cbp-spmenu-right" id="cbp-spmenu-s2">

</nav>

<script type="text/javascript" src="https://cdn.goeasy.io/goeasy.js"></script>
<script src="js/classie.js"></script>
<script type="text/javascript"
        src="http://webapi.amap.com/maps?v=1.4.0&key=b2aa70ae36eb3eaa847bced739886838&plugin=AMap.ToolBar,AMap.Geocoder,AMap.Walking"></script>
<script type="text/javascript" src="http://cache.amap.com/lbs/static/addToolbar.js"></script>
<script src="http://webapi.amap.com/js/marker.js"></script>
<script src="http://webapi.amap.com/ui/1.0/main.js?v=1.0.11"></script>
<!-- UI组件库 1.0 侧滑栏-->
<script>
    var $menuLeft = $('#cbp-spmenu-s1'),$menuRight = $('#cbp-spmenu-s3'),
        menuLeft = document.getElementById('cbp-spmenu-s1'),
        menuRight = document.getElementById('cbp-spmenu-s2'),
        menuRight2 = document.getElementById('cbp-spmenu-s3'),
        showLeft = document.getElementById('showLeft'),
        showRight = document.getElementById('showRight'),
        showRightPush = document.getElementById('showRightPush'),
        body = document.body;

    showLeft.onclick = function () {
        if (targetIndex === -1) {
            return;
        }
        classie.toggle(this, 'active');
        classie.toggle(menuLeft, 'cbp-spmenu-open');
    };
    showRight.onclick = function () {
        showYG('yg');
        showYG('yiyuan')
//        classie.toggle(this, 'active');
//        classie.toggle(menuRight, 'cbp-spmenu-open');
    };
    showRightPush.onclick = function () {
        classie.toggle(this, 'active');
        classie.toggle(body, 'cbp-spmenu-push-toleft');
        classie.toggle(menuRight2, 'cbp-spmenu-open');
    };
    showRightPush.click();

    //右侧边栏开关 1开
    function rightSwitch(type) {
        if(1===type){
            if($menuRight.css('right')==="-240px"){showRightPush.click();}
        }else if(0===type){
            if($menuRight.css('right')==="0px"){showRightPush.click();}
        }
    }

    //左侧边栏开关 1开
    function leftSwitch(type) {
        if(1===type){
            if($menuLeft.css('left')==="-240px"){showLeft.click();}
        }else if(0===type){
            if($menuLeft.css('left')==="0px"){showLeft.click();}
        }
    }

</script>

<script type="text/javascript">

    var infoWindow;
    var targetWindow;
    var sosInitFlag = false;
    var targetIndex = -1;
    var zoomSize = 15;

    var map = new AMap.Map('container', {
        resizeEnable: true,
        zoom: 11,
        center: [120.195656, 30.272825]//杭州
    });

    var arrys=new Array(),nearYG=new Array(),arrayTD=new Array(),sosPeople=new Array();


    //    //标记志愿者
//    var arrys = [
//        [120.155566, 30.290042],
//        [120.155497, 30.288101],
//        [120.158973, 30.289847],
//        [120.154974, 30.292818],
//        [120.155819, 30.288286],
//        [120.157653, 30.288587],
//        [120.158511, 30.288916]
//    ];
//
//    //最近的三个志愿者坐标
//    var nearYG = [
//        [120.157653, 30.288587],
//        [120.154974, 30.292818],
//        [120.155566, 30.290042]
//    ];
//
//    //SOS急救通道
//    var arrayTD =
//        [
//            {name: '亲属', coords: [120.154156, 30.29186]},
//            {name: '家庭医生', coords: [120.162631, 30.289025]},
//            {name: '社区医院', coords: [120.154284, 30.293676]},
//            {name: '社工', coords: [120.162864,30.297601]}
//        ];
//
//    //SOS急救通道
//    var sosPeople =
//        [
//            {name: '胡大爷', coords: [120.157224, 30.288812],sosTime:'2017-10-06 10:11:00'},
//            {name: '李大爷', coords: [120.15673 , 30.293195],sosTime:'2017-10-06 10:11:00'},
//            {name: '张大爷', coords: [120.150035, 30.289452],sosTime:'2017-10-06 10:11:00'}
//        ];

    $(function(){
        var goEasy = new GoEasy({
            appkey: 'BC-c0b4462193fb40fd9911dc9db1df468b'
        });

        //接受消息
        goEasy.subscribe({
            channel: 'demo_channel',
            onMessage: function(message){
                console.info('Meessage received:'+$.parseJSON(message.content));
                var ret = $.parseJSON(message.content);
                arrys = ret.volunteerCoordsList;
                arrayTD = ret.sosMap;
                sosPeople.push(ret.targetMan);
                //大爷定位坐标
                openInfo(0,ret.targetMan.name,ret.targetMan.coords);
                rightSwitch(1);
            }
        });

        rightSwitch(1);
    });

    //在指定位置打开信息窗体
    function openInfo(index, username,coords) {
        targetIndex = index;
        if(coords){
            initMap(coords);
        }else {
            initMap(sosPeople[targetIndex].coords);
        }
        //构建信息窗体中显示的内容
        var info = [];
        info.push("<div><div><img style=\"float:left;\" src=\" http://ww2.sinaimg.cn/large/0060lm7Tly1fjzk3ejgrkj302r02pdfu.jpg \"/></div> ");
        info.push("<div style=\"padding:0px 0px 0px 4px;\"><b>" + username + "</b>");
        info.push("电话 : 010-84107000");
        info.push("SOS地址 :<t id='daye'>浙江省杭州市下城区朝晖街道朝晖九小区(潮王支路)朝晖九小区</t></div></div>");
        targetWindow = new AMap.InfoWindow({
            content: info.join("<br/>")  //使用默认信息窗体框样式，显示信息内容
        });
//        infoWindow.open(map, map.getCenter());
        targetWindow.open(map, sosPeople[targetIndex].coords);

        var dayeMarker = new AMap.Marker({
            map: map,
            position: sosPeople[targetIndex].coords,
            content:
            '<div class="daye">'+username+'</div>',
            offset: new AMap.Pixel(-15, -15)
        });
        // 设置点标记的动画效果，此处为弹跳效果
//        dayeMarker.setAnimation('AMAP_ANIMATION_BOUNCE');

        //事件监听
        AMap.event.addListener(dayeMarker, 'mouseover', function () {
            targetWindow.open(map, sosPeople[targetIndex].coords);
        });
        AMap.event.addListener(dayeMarker, 'click', function () {
            targetWindow.open(map, sosPeople[targetIndex].coords);
        });
        AMap.event.addListener(dayeMarker, 'mouseout', function () {
            targetWindow.close();
        });
        map.setZoomAndCenter(zoomSize, sosPeople[targetIndex].coords);
        leftSwitch(1);
        $('#username').text(username);
        //弹窗 START---------------------------------------------------------------------------------------------
        initSOS();
        //地理位置解析
        regeocoder(sosPeople[targetIndex].coords);

    }
    //弹窗  END-----------------------------------------------------------------------------------------------

    //志愿者-------------
    function showYG() {
        showRight.click();
        map.setZoomAndCenter(zoomSize, sosPeople[targetIndex].coords);
        // 设置缩放级别和中心点
        arrys.forEach(function (value, index, array) {
            var marker = new AMap.Marker({
                map: map,
                position: value,
                offset: new AMap.Pixel(-15, -31),
                content: "<t class='yigong'>"+"志愿者" + (index + 1)+"</t>"
            });

            //事件监听
            AMap.event.addListener(marker, 'mouseover', function () {
                openInfoWin(value, "志愿者" + (index + 1));
            });
            AMap.event.addListener(marker, 'click', function () {
                openInfoWin(value, "志愿者" + (index + 1));
            });
            AMap.event.addListener(marker, 'mouseout', function () {
                infoWindow.close();
            });
        });

        //步行导航
        walking(nearYG[targetIndex], sosPeople[targetIndex].coords);

    }


    //志愿者-------------
    function openInfoWin(coords, name) {
        AMapUI.loadUI(['overlay/SimpleInfoWindow'], function (SimpleInfoWindow) {
            infoWindow = new SimpleInfoWindow({
                //模板, underscore
                infoTitle: '<center><strong><%- title %></strong></center>',
                infoBody: '<p class="my-desc">' +
                //<%= 原值插入 ..
                '<center><%= img %></center>' +
                //<%- html编码后插入
                '<%= body %>' +
                '</p>',
                //模板数据
                infoTplData: {
                    title: name,
                    img: '<img src="http://ww2.sinaimg.cn/large/0060lm7Tly1fk0cb2hm12j3093086n02.jpg" style="width: 100px;"/>',
                    body: '<div><a href="javascript:callFun.call(\'hujiao\');" class="BIGbutton" id="hujiao">呼叫</a></div>'
                },

                //基点指向marker的头部位置
                offset: new AMap.Pixel(0, -31)
            });
            infoWindow.open(map, coords);
        });
    }

    //SOS位置定位
    function getLoc(type) {
        openInfoWin(arrayTD[type].coords, arrayTD[type].name);
        map.setZoomAndCenter(zoomSize, arrayTD[type].coords);
    }

    //SOS通道初始化
    function initSOS() {
        var tempArray = new Array();
        tempArray.push(arrayTD.doctor);
        tempArray.push(arrayTD.hospital);
        tempArray.push(arrayTD.relatives);
        tempArray.push(arrayTD.socialWorker);

        //显示亲属，家庭医生，社区医院坐标地址
        tempArray.forEach(function (value, index, array) {
            var SOSMark = new AMap.Marker({
                map: map,
                position: value.coords
            });
            SOSMark.setLabel({
                offset: new AMap.Pixel(20, 20),//修改label相对于maker的位置
                content: value.name
            });
            AMap.event.addListener(SOSMark, 'mouseover', function () {
                openInfoWin(value.coords, value.name);
            });
            AMap.event.addListener(SOSMark, 'mouseout', function () {
                infoWindow.close();
            });
        });
        sosInitFlag = true;
    }


    //逆地理编码
    var geocoder = new AMap.Geocoder({
        radius: 1000,
        extensions: "all"
    });
    var regeocoder = function(coords) {

        //逆地理编码
        geocoder.getAddress(coords, function (status, result) {
            if (status === 'complete' && result.info === 'OK') {
                //获得了有效的地址信息:
                $('#daye').html(result.regeocode.formattedAddress);
                return result.regeocode.formattedAddress;
            } else {
                console.error("逆地理编码失败" + result)
                return '';
            }
        });
    }

    //步行导航
    function walking(from, to) {
        var walking = new AMap.Walking({
            map: map
        });
        walking.search(from, to, function (status, result) {
            var instruction = "";
            result.routes[0].steps.forEach(function (value) {
                instruction += value.instruction + "<br/>";
            });
            $('#walking_navigation_info').html(instruction);
        });
    }

    //初始化地图
    function initMap(coords,isClear) {
        if(isClear){
            leftSwitch(0);
        }
        $('#walking_navigation_info').html('');
        if(!coords){
            coords = sosPeople[targetIndex].coords;
        }
        map = new AMap.Map('container', {
            resizeEnable: true,
            zoom: 15,
            center:coords
        });
    }

    //点击呼叫按钮事件
    var callFun = {
        call:function(domID){
            //修改a标签的href链接：
            $("#"+domID).attr('href','javascript:callFun.cancleCall(\''+domID+'\');');
            //修改文字：
            $("#"+domID).text('呼叫中......');
        },
        cancleCall:function(domID){
            //修改a标签的href链接：
            $("#"+domID).attr('href','javascript:callFun.call(\''+domID+'\');');
            //修改文字：
            $("#"+domID).text('呼叫');
        }
    };
</script>
</body>

</html>